package xyz.xuminghai.javafx_learn.scene.control;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 * 2023/5/24 1:51 星期三<br/>
 * <p>
 * 文本输入控件
 *
 * @author xuMingHai
 */
public class TextInputControlApp extends Application {

    private final VBox vBox = new VBox(30.0);

    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void init() {
        TextField textField = new TextField();
        textField.setPromptText("请输入文字");
        HBox hBox1 = new HBox(20.0, new Label("文本框"), textField);
        hBox1.setAlignment(Pos.CENTER);


        PasswordField passwordField = new PasswordField();
        passwordField.setPromptText("请输入密码");
        HBox hBox2 = new HBox(20.0, new Label("密码框"), passwordField);
        hBox2.setAlignment(Pos.CENTER);


        TextArea textArea = new TextArea();
        textArea.setPromptText("请输入长文本");
        textArea.setWrapText(true);
        textArea.setPrefSize(200.0, 100.0);
        HBox hBox3 = new HBox(20.0, new Label("文本域"), textArea);
        hBox3.setAlignment(Pos.CENTER);


        vBox.getChildren().addAll(hBox1, hBox2, hBox3);
        vBox.setAlignment(Pos.CENTER);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle(getClass().getSimpleName());
        Scene scene = new Scene(vBox, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
